package com.changgou;

import entity.FeignRequestInterceptor;
import entity.IdWorker;
import entity.TokenDecode;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import tk.mybatis.spring.annotation.MapperScan;

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients(basePackages = {"com.changgou.goods.feign", "com.changgou.user.feign", "com.changgou.pay.feign"})
@MapperScan(basePackages = "com.changgou.order.dao")
@EnableScheduling //开启定时任务
public class OrderApplication {
    public static void main(String[] args) {
        SpringApplication.run(OrderApplication.class, args);
    }

    //添加令牌拦截器
    @Bean
    public FeignRequestInterceptor feignRequestInterceptor() {
        return new FeignRequestInterceptor();
    }

    //添加令牌解析器
    @Bean
    public TokenDecode tokenDecode() {
        return new TokenDecode();
    }

    //订单号生成工具
    @Bean
    public IdWorker idWorker() {
        return new IdWorker(1, 1);
    }
}
